// run: $exec < input
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>

int const maxn = 101;
int const inf = 1 << 29;

int map[maxn][maxn];
int dist[maxn];
int n;

void dijkstra(int source)
{
	std::fill(dist, dist + n, inf);
	dist[source] = 0;
	typedef std::pair<int, int> extend_edge;
	std::priority_queue<extend_edge, std::vector<extend_edge>,
		std::greater<extend_edge> > pq;
	pq.push(std::make_pair(0, source));
	while (!pq.empty()) {
		extend_edge now = pq.top(); pq.pop();
		int u = now.second;
		if (dist[u] < now.first) continue;

		for (int i = 0; i < n; i++) {
			if (dist[i] > dist[u] + map[i][u]) {
				dist[i] = dist[u] + map[i][u];
				pq.push(std::make_pair(dist[i], i));
			}
		}
	}
}

int main()
{
	std::cin >> n;
	for (int i = 1; i < n; i++)
		for (int j = 0; j < i; j++) {
			std::string s; std::cin >> s;
			if (s[0] == 'x')
				map[j][i] = map[i][j] = inf;
			else {
				std::istringstream iss(s);
				iss >> map[j][i];
				map[i][j] = map[j][i];
			}
		}
	dijkstra(0);
	int ans = 0;
	for (int i = 0; i < n; i++) ans = std::max(ans, dist[i]);
	std::cout << ans << '\n';
}

